import { Device } from "@/api/interface/iot";
import http from "@/api";
import { ResPage } from "../../interface";

/**
 * @name 设备管理模块
 */
// * 获取设备列表
export const getDeviceListAll = (params?: any) => {
	return http.get<ResPage<Device.ResDeviceInfo[]>>(`/device/find/all`, params, { headers: { noLoading: true } });
};
// * 获取设备列表
export const getDeviceList = (params?: any) => {
	return http.get<ResPage<Device.ResDeviceInfo[]>>(`/device/find`, params, { headers: { noLoading: true } });
};
// * 新增设备
export const addDevice = (params?: any) => {
	return http.post(`/device/add`, params);
};
// * 删除设备
export const removeDevice = (params: { idSn: string }) => {
	return http.post(`/device/remove`, params);
};
// * 获取设备详情
export const getDevice = (params?: any) => {
	return http.get<Device.ResDeviceInfo>(`/device/get`, params);
};
// * 编辑设备
export const modifyDevice = (params?: any) => {
	return http.post(`/device/modify`, params);
};

// 另存为产品
export const saveToProduct = (params?: any) => {
	return http.post(`/device/save/product`, params);
};
// 同步设备
export const syncDevice = (params?: any) => {
	return http.post(`/device/config/set`, params);
};
// 查询参数
export const syncGetDevice = (params?: any) => {
	return http.post(`/device/config/get`, params);
};
// 设备批量分组
export const changeGroup = (params?: any) => {
	return http.post(`/device/changeGroup`, params);
};
// 端口检测
export const portDetect = (params?: any) => {
	return http.get(`/sys/port/detect`, params);
};

export const sendFunc = (params: any, loading?: boolean) => {
	return http.post(`/device/func/set`, params, { headers: { noLoading: !loading } });
};
// 获取协议列表
export const getProtocolList = (params?: any) => {
	return http.get<any>(`/device/protocol/find`, params);
};
// 查询设备历史参数(含日志)
export const getHistorysystem = (params?: any) => {
	return http.get<any>(`/device/historysystem/get`, params);
};
// 接口诊断
export const diagnose = (params?: any) => {
	return http.post<any>(`/device/channel/diagnose`, params);
};
